from models.task import ScanEvents
from apps.notify.display import Tips


def availability_has_no_event(obj_task_session, *arg, **kwargs) -> str:
    """
    If availability task has no event, return failed reason.
    :param obj_task_session:
    :param arg:
    :param kwargs:
    :return:
    """
    task_session_id = obj_task_session.task_session_id
    if not ScanEvents.objects.filter(task_session_id=task_session_id).first():
        return Tips().get(2)

    return ""


FAILED_CONDITIONS = (availability_has_no_event, )


def active_stop():
    pass


def monitor_closed():
    pass


def get_stopped_reason(task_config):
    tips = Tips()
    if task_config.get('is_disabled'):
        return tips.get(1)
    return tips.get(0)
